package Algorithm;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;

public class Test {
    public static void main(String[] args) {

    }

    // 先序遍历
    public void preTraverse(TreeNode root) {
        if (root != null) {
            System.out.println(root.val);
            preTraverse(root.left);
            preTraverse(root.right);
        }
    }

    // 中序遍历
    public void inTraverse(TreeNode root) {
        if (root != null) {
            inTraverse(root.left);
            System.out.println(root.val);
            inTraverse(root.right);
        }
    }

    // 后序遍历
    public void postTraverse(TreeNode root) {
        if (root != null) {
            postTraverse(root.left);
            postTraverse(root.right);
            System.out.println(root.val);
        }
    }
}

class TreeNode {
    public TreeNode left, right;
    public int val;

    public TreeNode(int val) {
        this.val = val;
    }
}



